package top.datacluster.basic.algorithm.leetcode;

import java.util.HashMap;
import java.util.Map;

public class Main {

    public int[] test(int[] nums, int target){
        Map<Integer, Integer> temp = new HashMap<>();
        int[] result = new int[2];
        for (int i = 0; i < nums.length; i++){
            int middle = target - nums[i];
            if (temp.containsKey(middle)){
                result[0] = temp.get(middle);
                result[1] = i;
                return result;
            }else{
                temp.put(nums[i], i);
            }
        }
        return result;
    }
}
